$(document).ready(function() {
    
    $("#avaliacaoForm").validate();        
    $('#tab').tabs();    
    
    
    $('input[id="date1"]').datepicker();
    $('input[id="date2"]').datepicker();
    
 });
 
$(function(){
    
    $('#avaliacaoForm').submit(function(){
        buscar('');
        return false;
    });
    
    if($('#avaliacaoForm').is('form')){
        buscar('');
    }

});

function seleciona(sel){
    var select1 = document.getElementById(sel);
    for (var i = 0; i < select1.length; i++){
        select1.options[i].selected = true;
    }
}

function carregando(divId){
    var elemento = $('#'+divId);
    if($('#edit').is('div')){
        elemento.html('<p style="margin-top: 9px; text-align:center;"><img src="../../images/ajax-loader3.gif" /></p>');   
    } else {
        elemento.html('<p style="margin-top: 9px; text-align:center;"><img src="../images/ajax-loader3.gif" /></p>');   
    }
    elemento.show();
}

function buscar(paramsPagination){
    var pUrl = "dosearch";
    if($('#edit').is('div')){
        pUrl = "../"+pUrl;
    }
    var params = $("#avaliacaoForm").serialize()+paramsPagination;
    $.ajax({
        type: 'post',
        url: pUrl,
        data: params,
        beforeSend: function(){
            carregando('updateMe');
        },
        success: function(data){
            $('#updateMe').html(data);
            $('#updateMe').show();
        }
     });
}